﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using EnvDTE;
using Comet.Infrastructure;

namespace Comet.ViewModel
{
    public class ConstructorFromDataMembersViewModel
    {
        public ObservableCollection<DataMemberViewModel> DataMembers
        {
        	get 
            { 
                return dataMembers; 
            }
        }

        private ObservableCollection<DataMemberViewModel> dataMembers = new ObservableCollection<DataMemberViewModel>();

        public ConstructorFromDataMembersViewModel(CodeClass codeClass)
        {
            if (codeClass == null)
            {
                throw new ArgumentNullException("codeClass");
            }

            InitialiazeDataMembers(codeClass);
        }

        private void InitialiazeDataMembers(CodeClass codeClass)
        {
            ExtractedDataMembers extractedDataMembers = CometUtils.ExtractDataMembers(codeClass);

            foreach (var dataMember in extractedDataMembers.Fields)
            {
                DataMembers.Add(new DataMemberViewModel(dataMember));
            }

            foreach (var dataMember in extractedDataMembers.Properties)
            {
                DataMembers.Add(new DataMemberViewModel(dataMember));
            }
        }


    }
}
